package com.juyu.miliao.api.service;

import com.juyu.miliao.api.dao.mysql.MakeMoneyDao;
import com.juyu.miliao.api.dao.mysql.UserInfoDao;
import com.juyu.miliao.api.domain.MakeMoneyVO;
import com.juyu.miliao.api.domain.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class MakeMoneyService {
    @Resource
    private MakeMoneyDao makeMoneyDao;
    @Resource
    private UserInfoDao userInfoDao;


    public int getMakeMoneyDepositSum(long userId) {
        return makeMoneyDao.getMakeMoneyDepositSum(userId);
    }

    public List<MakeMoneyVO> getMakeMoneyInfoList(Long userId) {
        List<MakeMoneyVO> makeMoneyList = makeMoneyDao.getMakeMoneyInfoList(userId);
        if(makeMoneyList.size()==0){
            return makeMoneyList;
        }
        makeMoneyList.forEach(i -> {
            User user = userInfoDao.getUserById(i.getPassiveUserId());
            i.setPassiveNickName(user.getNickName());
            i.setPassiveIcon(user.getIcon());
        });
        return  makeMoneyList;
    }
}
